{% macro styling() %}
    <link rel="stylesheet" href="{{ get_url(path="spectre/spectre.css") }}">
    <link rel="stylesheet" href="{{ get_url(path="theme.css") }}">

    {%- if config.extra.custom_css is defined -%}
        <link rel="stylesheet" href="{{ get_url(path="custom.css") }}">
    {% endif %}
{% endmacro styling %}

{% macro favicon() %}
    {%- if config.extra.favicon is defined -%}
        <link rel="shortcut icon" href="{{ get_url(path=config.extra.favicon) }}" type="image/x-icon" />
    {%- endif -%}
{% endmacro favicon %}

{% macro rss() %}
    {%- if config.generate_feed -%}
        <link rel="alternate" type="application/rss+xml" title="{{ config.title }} RSS" href="{{ get_url(path="rss.xml") }}">
    {%- endif -%}
{% endmacro rss %}

{% macro fonts() %}
{% endmacro fonts %}

{% macro description() %}
    {%- if section -%}
        {%-  if section.description -%}
            {{ section.description }}
        {%- else -%}
            {{ config.description }}
        {%- endif -%}
    {%- elif page -%}
        {%- if page.description -%}
            {{ page.description }}
        {%- elif page.summary -%}
            {{ page.summary | striptags | truncate(length=200) }}
        {%- else -%}
            {{ config.description }}
        {%- endif -%}
    {%- else -%}
    {{ config.description }}
    {%- endif -%}
{% endmacro description %}

{% macro general_meta() %}
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1">
    <meta name="description" content="{{ head::description() }}"/>
{% endmacro general_meta %}

{% macro katex() %}
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.16.0/dist/katex.min.css" integrity="sha384-Xi8rHCmBmhbuyyhbI88391ZKP2dmfnOl4rT9ZfRI7mLTdk1wblIUnrIq35nqwEvC" crossorigin="anonymous">

    <!-- The loading of KaTeX is deferred to speed up page rendering -->
    <script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.0/dist/katex.min.js" integrity="sha384-X/XCfMm41VSsqRNQgDerQczD69XqmjOOOwYQvr/uuC+j4OPoNhVgjdGFwhvN02Ja" crossorigin="anonymous"></script>

    <!-- To automatically render math in text elements, include the auto-render extension: -->
    <script>
        function doRenderMath() {
            renderMathInElement(document.body, {
                delimiters: [
                {left: "$$", right: "$$", display: true},
                {left: "$", right: "$", display: false},
                {left: "\\(", right: "\\)", display: false},
                {left: "\\begin{equation}", right: "\\end{equation}", display: true},
                {left: "\\begin{align}", right: "\\end{align}", display: true},
                {left: "\\begin{alignat}", right: "\\end{alignat}", display: true},
                {left: "\\begin{gather}", right: "\\end{gather}", display: true},
                {left: "\\begin{CD}", right: "\\end{CD}", display: true},
                {left: "\\[", right: "\\]", display: true}
                ]
            });
        }
    </script>
    <script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.0/dist/contrib/auto-render.min.js" integrity="sha384-+XBljXPPiv+OzfbB3cVmLHf4hdUFHlWNZN5spNQ7rmHTXpd7WvJum6fIACpNNfIR" crossorigin="anonymous"
        onload="doRenderMath()"></script>
{% endmacro katex %}